package com.aacar.controller;

import com.aacar.constant.ConsFiled;
import com.aacar.dto.Header;
import com.aacar.dto.ProductDto;
import com.aacar.dto.RegisterDto;
import com.aacar.dto.UserDto;
import com.aacar.entity.Member;
import com.aacar.entity.MobileHead;
import com.aacar.interceptor.MemLoginKeyValid;
import com.aacar.service.CheckCodeService;
import com.aacar.service.MemberService;
import com.aacar.service.MessageService;
import com.aacar.service.ProductService;
import com.aacar.utils.*;
import com.aacar.vo.CommonVo;
import com.aacar.vo.UserInfoVo;
import com.aacar.vo.UserVo;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mysql.jdbc.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;


@RestController
@RequestMapping("/product")
public class ProductController extends ValidController{
	private Logger logger = LoggerFactory.getLogger(this.getClass());
    
    @Resource
    private ProductService productService;

    @Autowired
    private  HttpServletRequest request;
    

    @RequestMapping(value = "/select/0", method = RequestMethod.POST)
    @ResponseBody
    @MemLoginKeyValid
    public Object find(@RequestBody ProductDto productDto){
    	logger.info("request:/product/select/0" + JSONObject.toJSONString(productDto));
        Header mobileHead = super.getMobileHead(request);
        productDto.setUserId(Long.valueOf(mobileHead.getUserId()));
		return ResultInfoUtil.setSuccessInfo(productService.getProduct(productDto),mobileHead.getService());
    }

    
}
